/*
翻转整个字符串
翻转单个字符串
*/
class Solution {
public:
    string ReverseSentence(string str) {
        //翻转整个字符串
        reverse(str.begin(), str.end());
        for(int i=0;i<str.size();i++)
        {
            //找到每个单词的边界翻转
            int j=i;
            while(str[j]!=' '&&j<str.size())
                j++;
            reverse(str.begin()+i, str.begin()+j);
            i=j;
        }
        return str;
    }
};